package com.invengo.testrfid.mvp.ui.holder;

import android.view.View;
import android.widget.TextView;

import com.invengo.testrfid.MyApplication;
import com.invengo.testrfid.R;
import com.invengo.testrfid.app.dao.RfidCageBind;
import com.invengo.testrfid.app.utils.Constant;

import butterknife.BindView;

public class UploadDetailHolder extends MyBaseHolder<RfidCageBind> {

    @BindView(R.id.tv_ana_detail_title)
    TextView tv_title;

    @BindView(R.id.tv_note_detail_time)
    TextView tv_subtitle;

    @BindView(R.id.tv_ana_detail_title_2)
    TextView tv_subtitle_2;

    @BindView(R.id.tv_err)
    TextView tv_err;

    public UploadDetailHolder(View itemView) {
        super(itemView);
    }

    @Override
    public void setData(RfidCageBind data, int position) {

        if (data.getIsBind()) {

            tv_err.setVisibility(View.GONE);
            tv_subtitle_2.setText("已上传");
            tv_subtitle_2.setTextColor(MyApplication.getContext().getResources().getColor(R.color.green_l_x));
        } else {

            tv_err.setVisibility(View.VISIBLE);
            tv_err.setText(data.getFailedMessage());
            tv_subtitle_2.setText("未上传");
            tv_subtitle_2.setTextColor(MyApplication.getContext().getResources().getColor(R.color.orange));
        }

        String[] split = data.getTagId().split(Constant.ValueOfSpare);
        tv_title.setText(split[0]+"\n"+split[1]);
        tv_subtitle.setText("集装箱编号：" + data.getCageId());
    }
}
